package com.santu.edu.supporter.biz.order.other.controller;

import com.santu.edu.supporter.biz.order.other.pojo.dto.OtherOrderDTO;
import com.santu.edu.supporter.biz.order.other.pojo.params.OtherOrderAddParam;
import com.santu.edu.supporter.biz.order.other.service.OtherOrderService;
import com.santu.edu.supporter.util.PageData;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

/**
 * @author luoyaoqi
 * @createTime 2024/2/22
 * @description
 */
@RestController
@Validated
@RequiredArgsConstructor
@RequestMapping("other")
public class OtherOrderController {

    private final OtherOrderService otherOrderService;

    @PostMapping("add")
    public Boolean addOrder(@RequestBody @Valid OtherOrderAddParam addParam) {
        return otherOrderService.addOrder(addParam);
    }

    @PostMapping("cancel")
    public Boolean cancelOrder(@Param("orderId不能为空") String orderId) {
        return otherOrderService.cancelOrder(orderId);
    }

    @GetMapping("get/by/orderCode")
    public PageData<OtherOrderDTO> getBuildingsList(@NotBlank(message = "schoolId不能为空")
                                                    String schoolId,
                                                    String userId,
                                                    Integer orderType,
                                                    int page,
                                                    int size) {
        return otherOrderService.getOrderList(schoolId, userId, orderType, page, size);
    }
}
